#!/bin/sh
#
# Copyright (C) 2016 NatShell.com
#


. /lib/functions/system.sh
. /lib/functions/uci-defaults.sh
. /lib/functions.sh
. /lib/ar71xx.sh

generate_ap143_common(){
	if [ "$dev" = "" ] && [ "$vlan" = "" ]; then
		ucidef_set_interfaces_lan "eth1 eth0"
                ucidef_add_switch "switch0" \
                        "0@eth1" "2:lan" "3:lan" "4:lan"  "1:lan"
		set network.lan.proto='dhcp'
		uci commit network
	fi
}

dev="$(uci -q get network.@switch_vlan[0].device)"
vlan="$(uci -q get network.@switch_vlan[0].vlan)"

board=$(ar71xx_board_name)

case "$board" in
	ns-301p |\
	ap143 |\
	ns-a160 |\
	ns-8-pw3 )
		generate_ap143_common
	;;
esac

## remove /etc/config/dev_state_test.sh 
## cloud server has bug on it
rm -rf /etc/config/dev_state_test.sh
exit 0
